package com._21cn.cms.article.entity;

import com._21cn.framework.utils.StringUtil;

import java.io.Serializable;

public class ArticleThumbPicture implements Serializable {
	private static final long serialVersionUID = -1L;	
	
	private Integer id;
	private Integer articleId;
	private String picHashcode;
	private String picUrl;
	private Integer picWidth;
	private Integer picHeight;
	private java.util.Date modifyTime;
	private Integer modifyUserId;
	private Integer orderNum;
	
    public void setId(Integer id) {  
        this.id = id;  
    }        
    public Integer getId() {  
        return this.id;  
    }  

    public void setArticleId(Integer articleId) {  
        this.articleId = articleId;  
    }        
    public Integer getArticleId() {  
        return this.articleId;  
    }  

    public void setPicHashcode(String picHashcode) {  
        this.picHashcode = picHashcode;  
    }        
    public String getPicHashcode() {  
        return this.picHashcode;  
    }  

    public void setPicUrl(String picUrl) {  
        this.picUrl = picUrl;  
    }        
    public String getPicUrl() {  
        return this.picUrl;  
    }
    public String getPicUrl(String code) {
        String picUrl = getPicUrl();
        if (StringUtil.isImageFile(picUrl)) {
            try {
                String[] thumbAry = picUrl.split("/");
                String imgSize = thumbAry[(thumbAry.length - 2)];
                picUrl = picUrl.replaceFirst("/" + imgSize + "/", "/" + code + "/");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return picUrl;
    }

    public void setPicWidth(Integer picWidth) {  
        this.picWidth = picWidth;  
    }        
    public Integer getPicWidth() {  
        return this.picWidth;  
    }  

    public void setPicHeight(Integer picHeight) {  
        this.picHeight = picHeight;  
    }        
    public Integer getPicHeight() {  
        return this.picHeight;  
    }  

    public void setModifyTime(java.util.Date modifyTime) {  
        this.modifyTime = modifyTime;  
    }        
    public java.util.Date getModifyTime() {  
        return this.modifyTime;  
    }  

    public void setModifyUserId(Integer modifyUserId) {  
        this.modifyUserId = modifyUserId;  
    }        
    public Integer getModifyUserId() {  
        return this.modifyUserId;  
    }  

    public void setOrderNum(Integer orderNum) {  
        this.orderNum = orderNum;  
    }        
    public Integer getOrderNum() {  
        return this.orderNum;  
    }

    public ArticleThumbPicture initWith( Article a ){
        this.articleId = a.getId();
        this.modifyTime = a.getModifyTime();
        this.modifyUserId = a.getModifyUserId();
        return this;
    }
}